<%@page import="com.gxuwz.medical.domain.family.Family"%>
<%@page import="com.gxuwz.medical.domain.medical.Medical"%>
<%@ page language="java" import="java.util.*" pageEncoding="utf-8"%>
<%@ include file="/common/base.jsp"%>

<!DOCTYPE html>
<html lang="zh-cn">
<head>
<base href="<%=basePath%>">

<title>家庭档案列表</title>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport"
	content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=no" />
<meta name="renderer" content="webkit">
<link rel="stylesheet" href="css/styles.css">
<link rel="stylesheet" href="css/admin.css">
<script type="text/javascript" src="js/jquery-1.4.4.min.js"></script>
<script type="text/javascript" src="js/admin.js"></script>
<!-- 引入第三方弹出对话框JS组件 -->
<script type="text/javascript" src="third/layer/layer.js"></script>
<script type="text/javascript">
//新增家庭成员
function addMember(id){
	layer.open({
		  type: 2, 
		  title:'新增家庭成员',
		  shade: 0.8,
		  shadeClose: true,
		  area: ['80%', '80%'],
		  content: '<%=path%>/system/FamilyServlet?m=member&id='+id
		}); 
}
</script>
</head>
<body>
	<form method="post" action="<%=path%>/system/FamilyServlet?m=list" id="listform">
		<div class="panel admin-panel">
			<div class="panel-head">
				<strong class="icon-reorder">家庭档案信息列表</strong>
			</div>
			<div class="padding border-bottom">
				<ul class="search" style="padding-left:10px;">
					<li><a class="button border-main icon-plus-square-o"
						href="system/FamilyServlet?m=input"> 添加家庭档案</a></li>
					<li>搜索：</li>
					<li><input type="text" placeholder="请输入搜索关键字" name="keywords"
						class="input"
						style="width:250px; line-height:17px;display:inline-block" />
						<button class="button border-main icon-search" type="submit"> 搜索</button></li>
				</ul>
			</div>
			<table class="table table-hover text-center">
				<tr>
					<th >序号</th>
					<th>家庭编号</th>
					<th>乡镇/村/组</th>
					<th>户主姓名</th>
					<th>家庭人口数</th>
					<th>农业人口数</th>
					<th>建档时间</th>
					<th>建档人</th>
					<th>操作</th>
				</tr>
				<%
					String pageNo = request.getParameter("pageNo");
				String key=request.getParameter("keywords");
					int p = pageNo == null ? 1 : Integer.parseInt(pageNo);
					FamilyDao dao = new FamilyDao();
					String sql = "select * from t_family where 1=1 ";
					Object[] params = {};
					Page pageBean=null;
					if(key!=null&&!key.equals("")){
						sql="select * from t_family a,t_person b where a.famicode=b.famicode and (a.famicode=? like '%"
						        + key + "%' or a.famicode like '%" 
								+ key + "%' or b.persname like '%" 
								+ key + "%')";
						params=new Object[1];
						params[0]=key;
						List<Family> list=dao.queryOjects(sql,params);
						pageBean=new Page(1,1,list);
					}
					else{
						pageBean = dao.queryOjectsByPage(sql, params, p,
							Constant.ROW);
					}
				%>
				<%
					for (int i = 0; i < pageBean.getDatas().size(); i++) {

						Family model = (Family) pageBean.getDatas().get(i);
				%>
				<tr>

					<td ><%=(i+1) %></td>
					<td><%=model.getFamicode() %></td>
					<td><%=model.getTown().getAreaname()+model.getVillage().getAreaname()+model.getGroupNo().getAreaname() %></td>
					<td><%=model.getHolder().getPersname() %></td>
					<td><%=model.getPopuNum() %></td>
					<td><%=model.getAgriNum() %></td>
					<td><%=model.getCreattime() %></td>
					<td><%=model.getCreator() %></td>
					<td><div class="button-group">
					<a class="button border-main"
								href="<%=path%>/system/FamilyServlet?m=member&id=<%=model.getFamicode()%>"><span
								class="icon-edit"></span>添加成员</a> 
							<a class="button border-main"
								href="<%=path%>/system/FamilyServlet?m=get&id=<%=model.getFamicode()%>"><span
								class="icon-edit"></span> 修改</a> <a class="button border-red"
								href="<%=path%>/system/FamilyServlet?m=del&famicode=<%=model.getFamicode()%>"><span
								class="icon-trash-o"></span> 删除</a>
						</div></td>
				</tr>
				<%
					}
				%>
			</table>
			<div class="pagelist">
				<%
					if (pageBean.hasPre()&&(key==null||key.equals(""))) {
				%>
				<a
					href="<%=path%>/system/FamilyServlet?m=list&pageNo=<%=pageBean.prePage()%>">上一页</a>
				<%
					} else {
				%>
				<a href="javascript:void(0)">上一页</a>
				<%
					}
				%>
				<%
					List<Integer> linkNums = pageBean.linkLumbers();
					for (int num : linkNums) {
						if (pageBean.isCurrent(num)) {
				%>
				<span class="current"><%=num%></span>
				<%
					} else {
				%>
				<a href="<%=path%>/system/FamilyServlet?m=list&pageNo=<%=num%>"><%=num%></a>
				<%
					}
					}
				%>
				<%
					if (pageBean.hasNext()&&(key==null||key.equals(""))) {
				%>
				<a
					href="<%=path%>/system/FamilyServlet?m=list&pageNo=<%=pageBean.lastPage()%>">下一页</a>
				<%
					} else {
				%>
				<a href="javascript:void(0)">下一页</a>
				<%
					}
				if(key==null||key.equals("")){
				%>
				<a
					href="<%=path%>/system/FamilyServlet?m=list&pageNo=<%=pageBean.getPages()%>">尾页</a>
					<%
				}
				else {
					%>
					<a href="javascript:void(0)">尾页</a>
					<%
					}
					%>
			</div>
		</div>
	</form>

</body>
</html>
